package indi.kider.server.appclient.api;

import indi.kider.common.model.apabus.Rent;
import indi.kider.common.model.employee.Tenant;
import indi.kider.server.appclient.service.related.LockService;
import indi.kider.server.appclient.service.related.TenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.vankid.common.model.base.CommonResponse;

import java.util.List;

@RestController
@RequestMapping(value = "client", produces = "application/json;charset=UTF-8")
public class AppClientController {
    @Autowired
    private LockService lockService;
    /**
     * @param tenant
     * @return
     * @api {POST} /opendoor
     * @apiGroup app-client
     * @apiDescription 用户开门
     * @apiParamExample 请求样例：
     * http://localhost:9002/app-client/client/opendoor
     * {"housesId":null,"remark":null}
     * @apiSuccessExample {json} 返回样例:
     * {
     * "status": "201",
     * "msg": "保存成功！",
     * "data": 1
     */
    @PostMapping("/opendoor")
    public CommonResponse openTheDoor(Tenant tenant) {
        return null;
    }


    @PutMapping("/rentHouse")
    public CommonResponse checkOutHouse(@RequestBody Rent rent) {
        return null;
    }


    @Autowired
    private TenantService tenantService;


    /**
     * @api {POST} tenant/friend
     * @apiGroup app-client
     * @apiDescription 租客邀请好友 mainId：租客的ID（不是好友的）
     * @apiParamExample 请求样例：
     * http://localhost:9002/app-client/client/tenant/friend
     * {"name":"shixj2","cardId":12212,"phone":"1221","nationality":"32","professional":"23","wxopenId":"121","mainId":10}
     * @apiSuccessExample {json} 返回样例:
     * {"status":"201","msg":"保存成功！","data":{"id":76,"name":"shixj1","cardId":"12212","phone":"1221","title":null,"nationality":"32","professional":"23","wxopenId":null,"state":1,"type":2,"friendsSize":null,"mainId":69}}
     */
    @PostMapping("tenant/friend")
    public CommonResponse addFriend(@RequestBody Tenant tenant) {
        return tenantService.addFriend(tenant);
    }

    /**
     * @api {GET} /{mainId}/friend
     * @apiGroup app-client
     * @apiDescription 根据id获取租客邀请的好友信息
     * @apiParamExample 请求样例：
     * http://localhost:9002/app-client/client/tenant/1/friend
     * @apiSuccessExample {json} 返回样例:0
     * {"status":"200","msg":"查询成功！","data":[{"id":1,"name":"shixj","cardId":12212,"phone":"1221","nationality":"32","professional":"23","wxopenId":"121"}]}
     */
    @GetMapping("tenant/{mainId}/friend")
    public CommonResponse<List<Tenant>> getTenants(@PathVariable Long mainId) {
        return tenantService.getTenants(mainId);
    }
}
